#pragma once

#include <QtWidgets/QMainWindow>
#include <QDrag>
#include "ui_VBoxLayoutItems.h"

#include "contentitem.h"

QT_BEGIN_NAMESPACE
namespace Ui { class VBoxLayoutItemsClass; };
QT_END_NAMESPACE

class VBoxLayoutItems : public QMainWindow
{
    Q_OBJECT

public:
    VBoxLayoutItems(QWidget *parent = nullptr);
    void setCurrentItem(ContentItem* item);
    void setTargetItem(ContentItem* item);
    void removeItem(ContentItem* item);
    void addItem(ContentItem* item);
    void insertItem(int idx, ContentItem* item);

    int indexOfWidget(ContentItem* item);

    ~VBoxLayoutItems();
protected:
    void mousePressEvent(QMouseEvent* event) override;
    void mouseMoveEvent(QMouseEvent* event) override;
    void dragEnterEvent(QDragEnterEvent* event) override;
    void dragLeaveEvent(QDragLeaveEvent* event)override;
    //void dragMoveEvent(QDragMoveEvent* event) override;
    void dropEvent(QDropEvent* event) override;
private:
    //bool readFile(const QString& filename);
    void performDrag();
private:
    Ui::VBoxLayoutItemsClass *ui;
    ContentItem* m_curItem;
    ContentItem* m_tarItem;
    QPoint m_startPos;
};
